<?php
/**
 * User: i@fedax.cn
 * Time: 2018/7/26 14:33
 */

namespace app\admin\model;


class OperateLog extends DataBase
{
    protected $name = 'operate_log';
    protected $autoWriteTimestamp = 'datetime';

    public function getTypeAttr($value)
    {
        $status = [1 => '普通', 2 => '警告', 3 => '严重'];
        return $status[$value];
    }

    /**
     * @param $page_config
     * @param $where
     * @param $order
     * @return \think\Paginator
     * @throws \think\exception\DbException
     */
    public function getDataList($page_config, $where, $order)
    {
        $dataList = $this->where($where)
            ->order($order)
            ->paginate($page_config);
        $adminModel = new Admin();
        foreach ($dataList as $k => $v) {
            $adminDetail = $adminModel::get($v['admin_id']);
            $dataList[$k]['admin_name'] = $adminDetail['admin_name'];
        }
        return $dataList;
    }

}